package simtools.xml;

import java.io.File;

import org.jdom.Document;
import org.jdom.Element;
import org.jdom.input.SAXBuilder;
import org.jdom.output.Format;
import org.jdom.output.XMLOutputter;

public class TestSurrogateContent {

	private static void showData(Element content) {
		try {
			Format format = Format.getPrettyFormat();
			format.setLineSeparator("\n");

			XMLOutputter out = new XMLOutputter(format);
			out.output(content, System.out);

		} catch (Exception e) {
			e.printStackTrace();
		}
	}

	public static void main(String[] args) {
		String fileVideos  	  = "xml/VideoObjects.xml";
		String fileSurrogates = "xml/Cache.xml";
		Document content;
		SurrogateContent surrogateContent = new SurrogateContent();
		
		try {
			SAXBuilder builder = new SAXBuilder();
			
			Document docVideos = builder.build(new File(fileVideos));
			
			builder = new SAXBuilder();
			Document docSurrogates = builder.build(new File(fileSurrogates));
			
			content = surrogateContent.setContent(docSurrogates, docVideos);
			showData(content.getRootElement());
			
		} catch (Exception e) {
			e.printStackTrace();
		}
	}
}
